﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Assist;
using YArchitech.Controls;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;

namespace YArchitech.Plumbing
{
	public partial class SprayCalculatePara : System.Windows.Forms.Form
	{
		public CalculateType CalTypePara { get; set; }

		public double ParticalLossPara { get; set; }

		public double WorstPressurePara { get; set; }

		public double EffectAreaPara { get; set; }

		public double CoefficientK { get; set; }

		public string DangerLevelPara { get; set; }

		public SprayCalculatePara()
		{
			this.InitializeComponent();
			new YJKProcessTools().ShowInTaskbarChange(this);
			base.Icon = (base.Icon = Resource.YArchitechIcon);
			this.CalTypePara = CalculateType.CalByCheckTheFirst;
			this.ParticalLossPara = 0.2;
			this.WorstPressurePara = 5.0;
			this.EffectAreaPara = 0.0;
			this.CoefficientK = 80.0;
			this.LevelCbx.SelectedItem = this.DangerLevelPara;
		}

		private void checkByStart_CheckedChanged(object sender, EventArgs e)
		{
			this.CalTypePara = CalculateType.CalByCheckTheFirst;
			this.worstPressureText.Text = "最不利喷头压力（m·H20):";
		}

		private void checkByWorst_CheckedChanged(object sender, EventArgs e)
		{
			this.CalTypePara = CalculateType.CalBycheckTheWorst;
			this.worstPressureText.Text = "入口压力（m·H20）";
		}

		private void buttonOK_Click(object sender, EventArgs e)
		{
			this.DangerLevelPara = (string)this.LevelCbx.SelectedItem;
			try
			{
				this.WorstPressurePara = Convert.ToDouble(this.worstPressure.Text);
			}
			catch (Exception ex)
			{
				ex.ToString();
				YJKMessageBox.Error("请输入一个有效的数字！");
			}
			try
			{
				this.EffectAreaPara = Convert.ToDouble(this.effectArea.Text);
			}
			catch (Exception ex2)
			{
				ex2.ToString();
				YJKMessageBox.Error("请输入一个有效的数字！");
			}
			try
			{
				this.CoefficientK = Convert.ToDouble(this.textBoxK.Text);
			}
			catch (Exception ex3)
			{
				ex3.ToString();
				YJKMessageBox.Error("请输入一个有效的数字！");
			}
			base.DialogResult = DialogResult.OK;
		}

		private void buttonCancel_Click(object sender, EventArgs e)
		{
			base.DialogResult = DialogResult.Cancel;
		}

		private void SprayCalculatePara_Load(object sender, EventArgs e)
		{
			this.checkByStart.Checked = (this.CalTypePara == CalculateType.CalByCheckTheFirst);
			this.checkByWorst.Checked = (this.CalTypePara == CalculateType.CalBycheckTheWorst);
			this.worstPressure.Text = this.WorstPressurePara.ToString();
			this.effectArea.Text = this.EffectAreaPara.ToString();
			this.textBoxK.Text = this.CoefficientK.ToString();
			this.LevelCbx.SelectedItem = this.DangerLevelPara;
		}
	}
}
